package com.hw.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author F1335240
 * @version 1.0
 * @date 2020/5/11 9:56
 **/
@Controller
@RequestMapping("/")
public class LoginController {

    @GetMapping("/login")
    public ModelAndView login(@RequestParam(value = "error", required = false) String error,
                              @RequestParam(value = "logout", required = false) String logout) {

        ModelAndView modelAndView = new ModelAndView();
        if (error != null) {
            modelAndView.addObject("error", "用户名或者密码不正确");
        }
        if (logout != null) {
            modelAndView.addObject("msg", "退出成功");
        }
        modelAndView.setViewName("login");
        return modelAndView;
    }

}
